// -----------------------------------------------------------------------------
// M A R I T I M E   R E S E A R C H   I N S T I T U T E   N E T H E R L A N D S
// -----------------------------------------------------------------------------
// Copyright (C) October 16, 2009 MARIN - All rights reserved - http://www.marin.nl
// -----------------------------------------------------------------------------
// Program  : various
// Module   : ???
// File     : Qshep2d.h
// -----------------------------------------------------------------------------

#ifndef QSHEP2D_H
#define	QSHEP2D_H

#include <vector>

// -----------------------------------------------------------------------------
// class Qshep2d
// -----------------------------------------------------------------------------
/// short description
/** long description */
// -----------------------------------------------------------------------------

struct Vertex
{
    double x;
    double y;
    Vertex(double xx, double yy) : x(xx), y(yy) {}
};

typedef std::vector<Vertex> Vertices;
typedef std::vector<double> Values;

class Qshep2d
{
public:

    Qshep2d();

    virtual ~Qshep2d();

    bool setKnownValues(const Vertices& xy, const Values& z);

    double getUnknownValue(const Vertex& xy);

    bool getUnknownValue(const Vertex& xy, double *pZ, double *pDX, double *pDY);

private:

    Qshep2d(const Qshep2d& a_other);
    Qshep2d & operator=(const Qshep2d& a_other);

    int     m_n;      // number of grid points, must be at least 6
    double* m_x;      // x coordinates of grid points
    double* m_y;      // y coordinates of grid points
    double* m_z;      // data values at grid points
    int*    m_lcell;
    int*    m_lnext;
    double  m_xmin;
    double  m_ymin;
    double  m_dx;
    double  m_dy;
    double  m_rmax;
    double* m_rsq;
    double* m_a;
    int     m_nr;     //the number of rows and columns in the cell grid m_lcell

/*    Input, int NQ, the number of data points to be used in the least */
/*    squares fit for coefficients defining the nodal functions Q(K). */
/*    A highly recommended value is NQ = 13. */
/*    NQ must be at least 5, and no greater than the minimum of 40 and N-1. */

/*    Input, int NW, the number of nodes within (and defining) the radii */
/*    of influence R(K) which enter into the weights W(K).  For N */
/*    sufficiently large, a recommended value is NW = 19.   NW must be */
/*    at least 1, and no greater than the minimum of 40 and N-1. */

/*    Input, int NR, the number of rows and columns in the cell grid */
/*    defined in subroutine STORE2.  A rectangle containing the nodes */
/*    is partitioned into cells in order to increase search efficiency. */
/*    NR = SQRT(N/3) is recommended.  NR must be at least 1. */

};

#endif // QSHEP2D_H

